<extend name="Public/base"/>

<block name="body">
    <style>
        .inname{
            background-color: white;
            top: 200px;
            width: 500px;
            height: 160px;
            position: fixed;
            border: 1px solid;
            left: 700px;
            display: none;
            text-align: center;
        }
    </style>
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>[{$title}] 列表</h2>
    </div>
    <div class="cf">
        <div class="search-form fr cf">
            <div class="sleft">
                <input type="text" name="nickname" class="search-input" value="{:I('nickname')}" placeholder="请输入微信昵称">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('WechatUsers/index')}"><i class="btn-search"></i></a>
            </div>

        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table">
        <div class="data-table table-striped">
            <table>
                <!-- 表头 -->
                <thead>
                    <tr>
                        <th>微信昵称</th>
                        <th>微信头像</th>
                        <th>业务员姓名</th>
                        <th>业务员授权码</th>
                        <th>操作</th>
                    </tr>
                </thead>

                <!-- 列表 -->
                <tbody>
                    <volist name="users" id="val">
                        <tr>
                            <td>{$val.nickname}</td>
                            <td><img src="{$val.headimgurl}"></td>
                            <td>{$val.cname}</td>
                            <td>{$val.ywym}</td>
                            <if condition="$val['status'] gt 0">
                                <td><a href="{:U('WechatUsers/delete','mid='.$val[id])}">删除</a></td>
                                <else/>
                                <td><a href="javascript:void(0);" class="doywy" data-nickname="{$val.nickname}" data-mid="{$val.id}">设为业务员</a></td>
                            </if>

                        </tr>
                    </volist>
                </tbody>
            </table>
        </div>
    </div>
    <div class="page">
        {$_page|default=''}
    </div>
    <div class="inname">
        <h2>业务员设置</h2>
        <div style="height: 10px;width: 3px"></div>
        <form action="{:U('WechatUsers/setywy')}" method="post">
            <input type="text" id="nickname" name="nickname" value="{$rs.nickname}" disabled>
            <input type="hidden" id="mid" name="mid" value="123">
            <div style="height: 10px;width: 3px"></div>
            <input type="text" id="cname" name="cname" placeholder="业务员姓名" value="" required>
            <div style="height: 10px;width: 3px"></div>
            <input type="text" id="ywym" name="ywym" placeholder="授权码（exp：ERT32）" value="">
            <div style="height: 10px;width: 3px"></div>
            <input type="submit" name="sub" class="btn submit-btn" value="提交" >
            <button class="btn btn-return" id="qx">取消</button>
        </form>
    </div>
</block>

<block name="script">
<script type="text/javascript">
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });

    $('.doywy').click(function(){
        var mid = $(this).data('mid');
        var nickname = $(this).data('nickname');
        $('#nickname').val(nickname);
        $('#mid').val(mid);
        $('.inname').toggle();
    });
    $('#qx').click(function(){
        $('#nickname').val('');
        $('#mid').val('');
        $('.inname').toggle();
    });

})
</script>
</block>
